< previous page page_149 next page >

Page 149
e10a6a0a59f035e870d90cca05b85fce.gif
    ByVal bottom_margin As Single)
Dim next_paragraph As String
Dim next_word As String
Dim pos As Integer

    ' Start at the top of the page.
    Printer.CurrentY = top_margin

    ' Repeat until the text is all printed.
    Do While Len(txt) > 0
        ' Get the next paragraph.
        pos = InStr(txt, vbCrLf)
        If pos = 0 Then
            ' Use the rest of the text.
            next_paragraph = Trim$(txt) 
            txt = ""
        Else
            ' Get the paragraph. 
            next_paragraph = Trim$(Left$(txt, pos - 1)) 
            txt = Mid$(txt, pos + Len(vbCrLf)) 
        End If 
          
        ' Indent the paragraph. 
        Printer.CurrentX = left_margin + indent 
          
        ' Print the paragraph. 
        Do While Len(next_paragraph) > 0 
            ' Get the next word. 
            pos = InStr(next_paragraph, " ") 
            If pos = 0 Then 
                ' Use the rest of the paragraph. 
                next_word = next_paragraph 
                next_paragraph = "" 
            Else 
                ' Get the word.
                next_word = Left$(next_paragraph, pos - 1)
                next_paragraph = _ 
                    Trim$(Mid$(next_paragraph, pos + 1))
            End If

            ' See if there is room for this word.
            If Printer.CurrentX + _
                Printer.TextWidth(next_word) > right_margin _
            Then
                ' It won't fit. Start a new line.
                Printer.Print
                Printer.CurrentX = left_margin

                ' See if we have room for a new line.
                If Printer.CurrentY + _

 
< previous page page_149 next page >